<?php

class Cms_Pager extends Doctrine_Pager
{
	private $Offset;
	private $Limit;
	private $Url;
	
	
	public function __construct($query,$url,$offset,$limit=10)
	{
		parent::__construct($query,$offset,$limit);
		
		$this->Offset 	= $offset;
		$this->Limit 	= $limit;
		$this->Url		= $url;
	}
	
	public function pagination()
	{	
		$pagination = NULL;
		
		$CurrentPage	=	$this->getPage();
		$Previous		=	$this->getPreviousPage();
		$Next			= 	$this->getNextPage();
		$LastPage		=	$this->getLastPage();
		
		if($Previous < $this->Offset)
			$pagination .= "<a href='". $this->Url . $Previous ."'>< Previous</a>";

		$pages = NULL;
		for($i=1;$i<=$LastPage;$i++)
			$pages[] = '<a href="'.$this->Url.'?page='.$i.'">' .$i ."</a> " ;
		$pagination	= implode('|',$pages);
		
		if($Next > $this->Offset)
			$pagination .= "<a href='". $this->Url . $Next ."'>Next ></a>";
		
		return $pagination;
	}
}